package com.orphan.audit.controller;
import com.orphan.util.dto.SettlementSupplierGoodsDto;
import com.orphan.util.dto.SupplierReturnDto;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/supplier_auditmq")
public class SupplierAuditMQ {
    @Autowired
    RabbitTemplate rabbitTemplate;
    @GetMapping("audit")
    public String audittest(){
        SupplierReturnDto supplierReturnDto = new SupplierReturnDto();
        rabbitTemplate.convertAndSend("directExchangeaudit","audit",supplierReturnDto);
        return "ok";
    }

//    @GetMapping("testorder")
//    public String testorder(){
//        SupplierReturnDto supplierReturnDto = new SupplierReturnDto();
//        SettlementSupplierGoodsDto goodsDto = new SettlementSupplierGoodsDto();
//        List<SettlementSupplierGoodsDto> list = new ArrayList<>();
//        supplierReturnDto.setOrderId("001");
//        supplierReturnDto.setTSupplierName("万达");
//        supplierReturnDto.setOrderNum("12");
//        supplierReturnDto.setOrderTime("2021-12-13");
//        supplierReturnDto.setTTotal(0f);
//        supplierReturnDto.setSupplierGoods(list);
//
//        goodsDto.setGoodsName("MATE10");
//        goodsDto.setPrice(2000);
//        goodsDto.setSize("手机");
//        goodsDto.setGoodsId(1);
//        list.add(goodsDto);
//
//        rabbitTemplate.convertAndSend("directExchangeaudit","audit",supplierReturnDto);
//        return "ok";
//    }
    @GetMapping("findAll")
    private List<SupplierReturnDto> findAll(){
        List<SupplierReturnDto> supplierReturnDtos = new ArrayList<>();
        rabbitTemplate.convertAndSend("directExchangeaudit","audit",supplierReturnDtos);
        return supplierReturnDtos;
    }

}
